﻿/*
 * Cratos Server - WCF Service
 * Cratos WCF Engine Base class
 * 
 * Copyright (c) 2011-2012 Draco
 * 
 * This file is part of Cratos.
 * 
 * Cratos is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * Cratos is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cratos.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *       .==.        .==.
 *      //'^\\      //^'\\
 *     // ^ ^\(\__/)/^ ^^\\
 *    //^ ^^ ^/6  6\ ^^ ^ \\
 *   //^ ^^ ^/( .. )\^ ^ ^ \\
 *  // ^^ ^/\| V""V|/\^ ^ ^ \\
 * //^^/\/ /  '~~'  \ \/\^ ^ \\
 *  ------------------------------------
 *  HERE BE DRAGONS
 *  
 *  Johan Dercksen - johan@draco.co.za
 */
using System;
using System.Linq;
using System.Text;
using System.Threading;
using System.Collections.Generic;

using Cratos.Tools.General;

namespace Cratos.Server.WcfService
{
	/// <summary>
	/// WCF Engine Base class
	/// </summary>
	public abstract class CratosWcfEngineBase
	{
		#region Class Constant declarations
		#endregion

		#region Class Event declarations
		/// <summary>
		/// Log Message event
		/// </summary>
		public event CratosLogMessageEventHandler LogMessage;
		#endregion

		#region Class Variable declarations
		#endregion

		#region Class Constructors & Destructors
		/// <summary>
		/// Class Constructor
		/// </summary>
		/// <param name="engineName">Engine Name</param>
		/// <param name="callbackContext">Callback Context</param>
		public CratosWcfEngineBase(string engineName, ICratosDualWcfServiceCallback callbackContext)
		{
			// Save the relevant value(s)
			this.Name            = engineName;
			this.CallbackContext = callbackContext;
		}
		#endregion

		#region Class Properties
		/// <summary>
		/// Engine Name
		/// </summary>
		public string Name { get; internal set; }

		/// <summary>
		/// Callback Context
		/// </summary>
		public ICratosDualWcfServiceCallback CallbackContext { get; set; }
		#endregion

		#region Class Methods
		/// <summary>
		/// Engine Processing method
		/// </summary>
		public abstract void EngineProcessing();

		/// <summary>
		/// Cratos Log Message Event handler
		/// </summary>
		/// <param name="msgSeverity">Message Severity</param>
		/// <param name="msgSource">Message Source</param>
		/// <param name="newMessage">Message</param>
		protected void OnLogMessage(CratosLogSeverity msgSeverity, string msgSource, string newMessage)
		{
			// Declare the required variables

			// Raise the relevant event if required
			if (this.LogMessage != null) { this.LogMessage(msgSeverity, msgSource, newMessage); }

			// Return to calling method
			return;
		}
		#endregion

		#region Class Support Methods
		#endregion
	}
}
